//
//  AdvancedIdentifySuccViewController.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/12.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "AdvancedIdentifySuccViewController.h"
#import "AuthenResultInfoTableViewCell.h"
#import "AuthenResultInfoHeaderView.h"

@interface AdvancedIdentifySuccViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *merchantArray;
@property(nonatomic,strong)NSMutableArray *merchantValueArray;

@end

@implementation AdvancedIdentifySuccViewController


-(NSMutableArray *)merchantArray
{
    if (_merchantArray == nil) {
        _merchantArray = [NSMutableArray array];
    }
    return _merchantArray;
}
-(NSMutableArray *)merchantValueArray
{
    if (_merchantValueArray == nil) {
        _merchantValueArray = [NSMutableArray array];
    }
    return _merchantValueArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"高级认证";
    self.view.backgroundColor = [UIColor colorWithRed:242 / 255.0 green:244 / 255.0 blue:246 / 255.0 alpha:1];
    //创建tableView
    [self createTableView];
    //添加已认证图片
    [self addImageView];
    
    //删除之前页面，返回到主页面
    [self deleteVC];
}
-(void)deleteVC
{
     NSMutableArray *array = [self.navigationController.viewControllers mutableCopy];
    //把不需要的页面删除
    NSArray *arrayB = @[@"2",@"3",@"4",@"5"];
    for (int j = 0; j < arrayB.count; j++) {
        NSString *a = [arrayB objectAtIndex:j];
        int b = [a intValue] - j;
        [array removeObjectAtIndex:b];
    }
    
    //把删除后的控制器数组再次复制
    [self.navigationController setViewControllers:[array copy]];
}

-(void)addImageView
{
    UIImageView *imv = [[UIImageView alloc] init];
    imv.image = [UIImage imageNamed:@"label_icon_yirenzheng"];
    imv.frame = CGRectMake(self.view.frame.size.width - 91, 0, 91, 91);
    [self.view addSubview:imv];
}
-(void)createTableView
{
    self.merchantArray = @[@"姓名",@"手机号",@"店铺名称",@"所在地"].mutableCopy;
    self.merchantValueArray = @[@"网大白",@"138****7838",@"星巴克",@"上海市闵行区合川路虹桥国际大楼5楼508"].mutableCopy;
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:(UITableViewStyleGrouped)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    [self.view addSubview:self.tableView];
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.tableView registerClass:[AuthenResultInfoTableViewCell class] forCellReuseIdentifier:@"cell"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.merchantValueArray.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AuthenResultInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == self.merchantValueArray.count - 1) {
        cell.lineView.hidden = YES;
    }
    cell.titleLab.text = self.merchantArray[indexPath.row];
    cell.tipsValueLab.text = self.merchantValueArray[indexPath.row];

    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    AuthenResultInfoHeaderView *headerView = [[AuthenResultInfoHeaderView alloc] init];
    headerView.tipsLab.text = @"基本信息";
    return headerView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && indexPath.row == 3) {
        return 84;
    }else
    {
        return 44;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01f;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.01)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

/*
//当前页面关闭右滑返回
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //禁用右滑返回
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    //恢复右滑返回
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
 */

@end
